package com.zhaojun.cloud.service.api.hystrix;

import com.zhaojun.cloud.service.api.RedisService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.Set;

/**
 * wwj
 * 2019/2/18  17:06
 */
@Component
public class HystrixFallBackRedisService implements FallbackFactory<RedisService> {

    private Logger logger = LoggerFactory.getLogger(HystrixFallBackRedisService.class);

    @Override
    public RedisService create(Throwable throwable) {
        logger.error("【HystrixFallBackRedisService】：接口异常:"+throwable,throwable);
        return new RedisService() {
            @Override
            public String get(String key) {
                return null;
            }

            @Override
            public Boolean set(String key, String value) {
                return false;
            }

            @Override
            public String hget(String hkey, String key) {
                return null;
            }

            @Override
            public Boolean hset(String hkey, String key, String value) {
                return false;
            }

            @Override
            public int hsize(String hkey) {
                return 0;
            }

            @Override
            public Set hkeys(String hkey) {
                return null;
            }

            @Override
            public Collection hvalues(String hkey) {
                return null;
            }

            @Override
            public Long incr(String key) {
                return null;
            }

            @Override
            public Long decr(String key) {
                return null;
            }

            @Override
            public Boolean expire(String key, Long second) {
                return false;
            }

            @Override
            public Long ttl(String key) {
                return null;
            }

            @Override
            public Boolean del(String key) {
                return false;
            }

            @Override
            public Long hdel(String hkey, String key) {
                return null;
            }
        };
    }
}
